package com.turbo.boot.crawler.spider.worker.impl.info;

import com.alibaba.fastjson.JSON;
import com.turbo.boot.crawler.spider.worker.BaseTurboCrawlerPageParser;
import com.xuxueli.crawler.annotation.PageFieldSelect;
import com.xuxueli.crawler.annotation.PageSelect;
import lombok.Getter;
import lombok.Setter;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.stereotype.Service;

/**
 * 描述
 *
 * @author wuyn
 * @since 2024/4/19
 */
@Service("zjSemDealCrawlerPageParser")
public class ZjSemDealCrawlerPageParser extends BaseTurboCrawlerPageParser<ZjSemDealCrawlerPageParser.PageVo> {

    @Override
    public void parse(Document html, Element pageVoElement, PageVo pageVo) {
        // 解析封装 PageVo 对象
        String pageUrl = html.baseUri();
        System.out.println(pageUrl + "：" + pageVo.toString());
        // 处理业务代码
    }


    @Setter
    @Getter
    @PageSelect(cssQuery = "#div_table table > tbody > tr")
    public static class PageVo {

        @PageFieldSelect(cssQuery = "td:nth-child(1)")
        private String no;

        // 起拍价
        @PageFieldSelect(cssQuery = "td:nth-child(2)")
        private String type;

        // 起拍价
        @PageFieldSelect(cssQuery = "td:nth-child(3)")
        private String weight;

        // 保证金
        @PageFieldSelect(cssQuery = "td:nth-child(4)")
        private String load;

        @PageFieldSelect(cssQuery = "td:nth-child(5)")
        private String createTime;

        @PageFieldSelect(cssQuery = "td:nth-child(6)")
        private String dealAmt;


        @PageFieldSelect(cssQuery = "td:nth-child(7)")
        private String dealTime;

        @Override
        public String toString() {
            return JSON.toJSONString(this);
        }
    }
}
